// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.znet;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import se.krka.kahlua.vm.KahluaTable;
import zombie.core.logger.ExceptionLogger;
import zombie.core.textures.PNGDecoder;

public class SteamWorkshopItem {
    private String workshopFolder;
    private String PublishedFileId;
    private String title = "";
    private String description = "";
    private String visibility = "public";
    private final ArrayList<String> tags = new ArrayList();
    private String changeNote = "";
    private boolean bHasMod;
    private boolean bHasMap;
    private final ArrayList<String> modIDs = new ArrayList();
    private final ArrayList<String> mapFolders = new ArrayList();
    private static final int VERSION1 = 1;
    private static final int LATEST_VERSION = 1;

    public SteamWorkshopItem(String _workshopFolder) {
        this.workshopFolder = _workshopFolder;
    }

    public String getContentFolder() {
        return this.workshopFolder + File.separator + "Contents";
    }

    public String getFolderName() {
        return new File(this.workshopFolder).getName();
    }

    public void setID(String ID) {
        if (ID != null && !SteamUtils.isValidSteamID(ID)) {
            ID = null;
        }

        this.PublishedFileId = ID;
    }

    public String getID() {
        return this.PublishedFileId;
    }

    public void setTitle(String _title) {
        if (_title == null) {
            _title = "";
        }

        this.title = _title;
    }

    public String getTitle() {
        return this.title;
    }

    public void setDescription(String _description) {
        if (_description == null) {
            _description = "";
        }

        this.description = _description;
    }

    public String getDescription() {
        return this.description;
    }

    public void setVisibility(String _visibility) {
        this.visibility = _visibility;
    }

    public String getVisibility() {
        return this.visibility;
    }

    public void setVisibilityInteger(int v) {
        switch (v) {
            case 0:
                this.visibility = "public";
                break;
            case 1:
                this.visibility = "friendsOnly";
                break;
            case 2:
                this.visibility = "private";
                break;
            case 3:
                this.visibility = "unlisted";
                break;
            default:
                this.visibility = "public";
        }
    }

    public int getVisibilityInteger() {
        if ("public".equals(this.visibility)) {
            return 0;
        } else if ("friendsOnly".equals(this.visibility)) {
            return 1;
        } else if ("private".equals(this.visibility)) {
            return 2;
        } else {
            return "unlisted".equals(this.visibility) ? 3 : 0;
        }
    }

    public void setTags(ArrayList<String> _tags) {
        this.tags.clear();
        this.tags.addAll(_tags);
    }

    public static ArrayList<String> getAllowedTags() {
        ArrayList arrayList = new ArrayList();
        File file = zombie.ZomboidFileSystem.instance.getMediaFile("WorkshopTags.txt");

        try {
            FileReader fileReader = new FileReader(file);

            try {
                BufferedReader bufferedReader = new BufferedReader(fileReader);

                String string;
                try {
                    while ((string = bufferedReader.readLine()) != null) {
                        string = string.trim();
                        if (!string.isEmpty()) {
                            arrayList.add(string);
                        }
                    }
                } catch (Throwable throwable0) {
                    try {
                        bufferedReader.close();
                    } catch (Throwable throwable1) {
                        throwable0.addSuppressed(throwable1);
                    }

                    throw throwable0;
                }

                bufferedReader.close();
            } catch (Throwable throwable2) {
                try {
                    fileReader.close();
                } catch (Throwable throwable3) {
                    throwable2.addSuppressed(throwable3);
                }

                throw throwable2;
            }

            fileReader.close();
        } catch (Exception exception) {
            ExceptionLogger.logException(exception);
        }

        return arrayList;
    }

    public ArrayList<String> getTags() {
        return this.tags;
    }

    public String getSubmitDescription() {
        String string = this.getDescription();
        if (!string.isEmpty()) {
            string = string + "\n\n";
        }

        string = string + "Workshop ID: " + this.getID();

        for (int int0 = 0; int0 < this.modIDs.size(); int0++) {
            string = string + "\nMod ID: " + (String)this.modIDs.get(int0);
        }

        for (int int1 = 0; int1 < this.mapFolders.size(); int1++) {
            string = string + "\nMap Folder: " + (String)this.mapFolders.get(int1);
        }

        return string;
    }

    public String[] getSubmitTags() {
        ArrayList arrayList = new ArrayList();
        arrayList.addAll(this.tags);
        return (String[])arrayList.toArray(new String[arrayList.size()]);
    }

    public String getPreviewImage() {
        return this.workshopFolder + File.separator + "preview.png";
    }

    public void setChangeNote(String _changeNote) {
        if (_changeNote == null) {
            _changeNote = "";
        }

        this.changeNote = _changeNote;
    }

    public String getChangeNote() {
        return this.changeNote;
    }

    public boolean create() {
        return SteamWorkshop.instance.CreateWorkshopItem(this);
    }

    public boolean submitUpdate() {
        return SteamWorkshop.instance.SubmitWorkshopItem(this);
    }

    public boolean getUpdateProgress(KahluaTable kahluaTable) {
        if (kahluaTable == null) {
            throw new NullPointerException("table is null");
        } else {
            long[] _long = new long[2];
            if (SteamWorkshop.instance.GetItemUpdateProgress(_long)) {
                System.out.println(_long[0] + "/" + _long[1]);
                kahluaTable.rawset("processed", (double)_long[0]);
                kahluaTable.rawset("total", (double)Math.max(_long[1], 1L));
                return true;
            } else {
                return false;
            }
        }
    }

    public int getUpdateProgressTotal() {
        return 1;
    }

    private String validateFileTypes(Path path0) {
        try {
            DirectoryStream directoryStream = Files.newDirectoryStream(path0);

            String string0;
            label92: {
                label93: {
                    try {
                        for (Path path1 : directoryStream) {
                            if (Files.isDirectory(path1, new LinkOption[0])) {
                                String string1 = this.validateFileTypes(path1);
                                if (string1 != null) {
                                    string0 = string1;
                                    break label92;
                                }
                            } else {
                                String string2 = path1.getFileName().toString();
                                if (!string2.equalsIgnoreCase("pyramid.zip")
                                    && (
                                        string2.endsWith(".exe")
                                            || string2.endsWith(".dll")
                                            || string2.endsWith(".bat")
                                            || string2.endsWith(".app")
                                            || string2.endsWith(".dylib")
                                            || string2.endsWith(".sh")
                                            || string2.endsWith(".so")
                                            || string2.endsWith(".zip")
                                    )) {
                                    string0 = "FileTypeNotAllowed";
                                    break label93;
                                }
                            }
                        }
                    } catch (Throwable throwable0) {
                        if (directoryStream != null) {
                            try {
                                directoryStream.close();
                            } catch (Throwable throwable1) {
                                throwable0.addSuppressed(throwable1);
                            }
                        }

                        throw throwable0;
                    }

                    if (directoryStream != null) {
                        directoryStream.close();
                    }

                    return null;
                }

                if (directoryStream != null) {
                    directoryStream.close();
                }

                return string0;
            }

            if (directoryStream != null) {
                directoryStream.close();
            }

            return string0;
        } catch (Exception exception) {
            exception.printStackTrace();
            return "IOError";
        }
    }

    private String validateModDotInfo(Path path) {
        String string0 = null;

        try {
            FileReader fileReader = new FileReader(path.toFile());

            try {
                BufferedReader bufferedReader = new BufferedReader(fileReader);

                String string1;
                try {
                    while ((string1 = bufferedReader.readLine()) != null) {
                        if (string1.startsWith("id=")) {
                            string0 = string1.replace("id=", "").trim();
                            break;
                        }
                    }
                } catch (Throwable throwable0) {
                    try {
                        bufferedReader.close();
                    } catch (Throwable throwable1) {
                        throwable0.addSuppressed(throwable1);
                    }

                    throw throwable0;
                }

                bufferedReader.close();
            } catch (Throwable throwable2) {
                try {
                    fileReader.close();
                } catch (Throwable throwable3) {
                    throwable2.addSuppressed(throwable3);
                }

                throw throwable2;
            }

            fileReader.close();
        } catch (FileNotFoundException fileNotFoundException) {
            return "MissingModDotInfo";
        } catch (IOException iOException) {
            iOException.printStackTrace();
            return "IOError";
        }

        if (string0 != null && !string0.isEmpty()) {
            this.modIDs.add(string0);
            return null;
        } else {
            return "InvalidModDotInfo";
        }
    }

    private String validateMapDotInfo(Path var1) {
        return null;
    }

    private String validateMapFolder(Path path0) {
        boolean _boolean = false;

        try {
            DirectoryStream directoryStream;
            label68: {
                directoryStream = Files.newDirectoryStream(path0);

                String string0;
                try {
                    Iterator iterator = directoryStream.iterator();

                    while (true) {
                        if (!iterator.hasNext()) {
                            break label68;
                        }

                        Path path1 = (Path)iterator.next();
                        if (!Files.isDirectory(path1, new LinkOption[0]) && "map.info".equals(path1.getFileName().toString())) {
                            String string1 = this.validateMapDotInfo(path1);
                            if (string1 != null) {
                                string0 = string1;
                                break;
                            }

                            _boolean = true;
                        }
                    }
                } catch (Throwable throwable0) {
                    if (directoryStream != null) {
                        try {
                            directoryStream.close();
                        } catch (Throwable throwable1) {
                            throwable0.addSuppressed(throwable1);
                        }
                    }

                    throw throwable0;
                }

                if (directoryStream != null) {
                    directoryStream.close();
                }

                return string0;
            }

            if (directoryStream != null) {
                directoryStream.close();
            }
        } catch (Exception exception) {
            exception.printStackTrace();
            return "IOError";
        }

        if (!_boolean) {
            return "MissingMapDotInfo";
        } else {
            this.mapFolders.add(path0.getFileName().toString());
            return null;
        }
    }

    private String validateMapsFolder(Path path0) {
        boolean _boolean = false;

        try {
            DirectoryStream directoryStream;
            label65: {
                directoryStream = Files.newDirectoryStream(path0);

                String string0;
                try {
                    Iterator iterator = directoryStream.iterator();

                    while (true) {
                        if (!iterator.hasNext()) {
                            break label65;
                        }

                        Path path1 = (Path)iterator.next();
                        if (Files.isDirectory(path1, new LinkOption[0])) {
                            String string1 = this.validateMapFolder(path1);
                            if (string1 != null) {
                                string0 = string1;
                                break;
                            }

                            _boolean = true;
                        }
                    }
                } catch (Throwable throwable0) {
                    if (directoryStream != null) {
                        try {
                            directoryStream.close();
                        } catch (Throwable throwable1) {
                            throwable0.addSuppressed(throwable1);
                        }
                    }

                    throw throwable0;
                }

                if (directoryStream != null) {
                    directoryStream.close();
                }

                return string0;
            }

            if (directoryStream != null) {
                directoryStream.close();
            }
        } catch (Exception exception) {
            exception.printStackTrace();
            return "IOError";
        }

        if (!_boolean) {
            return null;
        } else {
            this.bHasMap = true;
            return null;
        }
    }

    private String validateMediaFolder(Path path0) {
        try {
            DirectoryStream directoryStream = Files.newDirectoryStream(path0);

            String string0;
            label55: {
                try {
                    for (Path path1 : directoryStream) {
                        if (Files.isDirectory(path1, new LinkOption[0]) && "maps".equals(path1.getFileName().toString())) {
                            String string1 = this.validateMapsFolder(path1);
                            if (string1 != null) {
                                string0 = string1;
                                break label55;
                            }
                        }
                    }
                } catch (Throwable throwable0) {
                    if (directoryStream != null) {
                        try {
                            directoryStream.close();
                        } catch (Throwable throwable1) {
                            throwable0.addSuppressed(throwable1);
                        }
                    }

                    throw throwable0;
                }

                if (directoryStream != null) {
                    directoryStream.close();
                }

                return null;
            }

            if (directoryStream != null) {
                directoryStream.close();
            }

            return string0;
        } catch (Exception exception) {
            exception.printStackTrace();
            return "IOError";
        }
    }

    private String validateModFolder(Path path0) {
        boolean _boolean = false;

        try {
            DirectoryStream directoryStream;
            label82: {
                String string0;
                label83: {
                    directoryStream = Files.newDirectoryStream(path0);

                    try {
                        Iterator iterator = directoryStream.iterator();

                        while (true) {
                            if (!iterator.hasNext()) {
                                break label82;
                            }

                            Path path1 = (Path)iterator.next();
                            if (Files.isDirectory(path1, new LinkOption[0])) {
                                if ("media".equals(path1.getFileName().toString())) {
                                    String string1 = this.validateMediaFolder(path1);
                                    if (string1 != null) {
                                        string0 = string1;
                                        break label83;
                                    }
                                }
                            } else if ("mod.info".equals(path1.getFileName().toString())) {
                                String string2 = this.validateModDotInfo(path1);
                                if (string2 != null) {
                                    string0 = string2;
                                    break;
                                }

                                _boolean = true;
                            }
                        }
                    } catch (Throwable throwable0) {
                        if (directoryStream != null) {
                            try {
                                directoryStream.close();
                            } catch (Throwable throwable1) {
                                throwable0.addSuppressed(throwable1);
                            }
                        }

                        throw throwable0;
                    }

                    if (directoryStream != null) {
                        directoryStream.close();
                    }

                    return string0;
                }

                if (directoryStream != null) {
                    directoryStream.close();
                }

                return string0;
            }

            if (directoryStream != null) {
                directoryStream.close();
            }
        } catch (Exception exception) {
            exception.printStackTrace();
            return "IOError";
        }

        return !_boolean ? "MissingModDotInfo" : null;
    }

    private String validateModsFolder(Path path0) {
        boolean _boolean = false;

        try {
            DirectoryStream directoryStream;
            label75: {
                String string0;
                label76: {
                    directoryStream = Files.newDirectoryStream(path0);

                    String string1;
                    try {
                        Iterator iterator = directoryStream.iterator();

                        while (true) {
                            if (!iterator.hasNext()) {
                                break label75;
                            }

                            Path path1 = (Path)iterator.next();
                            if (!Files.isDirectory(path1, new LinkOption[0])) {
                                string1 = "FileNotAllowedInMods";
                                break;
                            }

                            string1 = this.validateModFolder(path1);
                            if (string1 != null) {
                                string0 = string1;
                                break label76;
                            }

                            _boolean = true;
                        }
                    } catch (Throwable throwable0) {
                        if (directoryStream != null) {
                            try {
                                directoryStream.close();
                            } catch (Throwable throwable1) {
                                throwable0.addSuppressed(throwable1);
                            }
                        }

                        throw throwable0;
                    }

                    if (directoryStream != null) {
                        directoryStream.close();
                    }

                    return string1;
                }

                if (directoryStream != null) {
                    directoryStream.close();
                }

                return string0;
            }

            if (directoryStream != null) {
                directoryStream.close();
            }
        } catch (Exception exception) {
            exception.printStackTrace();
            return "IOError";
        }

        if (!_boolean) {
            return "EmptyModsFolder";
        } else {
            this.bHasMod = true;
            return null;
        }
    }

    private String validateBuildingsFolder(Path var1) {
        return null;
    }

    private String validateCreativeFolder(Path var1) {
        return null;
    }

    public String validatePreviewImage(Path path) throws IOException {
        if (Files.exists(path, new LinkOption[0]) && Files.isReadable(path) && !Files.isDirectory(path, new LinkOption[0])) {
            if (Files.size(path) > 1024000L) {
                return "PreviewFileSize";
            } else {
                try {
                    FileInputStream fileInputStream = new FileInputStream(path.toFile());

                    String string;
                    label59: {
                        try {
                            BufferedInputStream bufferedInputStream;
                            label70: {
                                bufferedInputStream = new BufferedInputStream(fileInputStream);

                                try {
                                    PNGDecoder pNGDecoder = new PNGDecoder(bufferedInputStream, false);
                                    if (pNGDecoder.getWidth() == 256 && pNGDecoder.getHeight() == 256) {
                                        break label70;
                                    }

                                    string = "PreviewDimensions";
                                } catch (Throwable throwable0) {
                                    try {
                                        bufferedInputStream.close();
                                    } catch (Throwable throwable1) {
                                        throwable0.addSuppressed(throwable1);
                                    }

                                    throw throwable0;
                                }

                                bufferedInputStream.close();
                                break label59;
                            }

                            bufferedInputStream.close();
                        } catch (Throwable throwable2) {
                            try {
                                fileInputStream.close();
                            } catch (Throwable throwable3) {
                                throwable2.addSuppressed(throwable3);
                            }

                            throw throwable2;
                        }

                        fileInputStream.close();
                        return null;
                    }

                    fileInputStream.close();
                    return string;
                } catch (IOException iOException) {
                    iOException.printStackTrace();
                    return "PreviewFormat";
                }
            }
        } else {
            return "PreviewNotFound";
        }
    }

    public String validateContents() {
        this.bHasMod = false;
        this.bHasMap = false;
        this.modIDs.clear();
        this.mapFolders.clear();

        try {
            Path path0 = FileSystems.getDefault().getPath(this.getContentFolder());
            if (!Files.isDirectory(path0, new LinkOption[0])) {
                return "MissingContents";
            } else {
                Path path1 = FileSystems.getDefault().getPath(this.getPreviewImage());
                String string0 = this.validatePreviewImage(path1);
                if (string0 != null) {
                    return string0;
                } else {
                    boolean _boolean = false;

                    try {
                        DirectoryStream directoryStream;
                        label143: {
                            String string1;
                            label144: {
                                label145: {
                                    label146: {
                                        label147: {
                                            directoryStream = Files.newDirectoryStream(path0);

                                            try {
                                                Iterator iterator = directoryStream.iterator();

                                                while (true) {
                                                    if (!iterator.hasNext()) {
                                                        break label143;
                                                    }

                                                    Path path2 = (Path)iterator.next();
                                                    if (!Files.isDirectory(path2, new LinkOption[0])) {
                                                        string1 = "FileNotAllowedInContents";
                                                        break;
                                                    }

                                                    if ("buildings".equals(path2.getFileName().toString())) {
                                                        string0 = this.validateBuildingsFolder(path2);
                                                        if (string0 != null) {
                                                            string1 = string0;
                                                            break label144;
                                                        }
                                                    } else if ("creative".equals(path2.getFileName().toString())) {
                                                        string0 = this.validateCreativeFolder(path2);
                                                        if (string0 != null) {
                                                            string1 = string0;
                                                            break label145;
                                                        }
                                                    } else {
                                                        if (!"mods".equals(path2.getFileName().toString())) {
                                                            string1 = "FolderNotAllowedInContents";
                                                            break label147;
                                                        }

                                                        string0 = this.validateModsFolder(path2);
                                                        if (string0 != null) {
                                                            string1 = string0;
                                                            break label146;
                                                        }
                                                    }

                                                    _boolean = true;
                                                }
                                            } catch (Throwable throwable0) {
                                                if (directoryStream != null) {
                                                    try {
                                                        directoryStream.close();
                                                    } catch (Throwable throwable1) {
                                                        throwable0.addSuppressed(throwable1);
                                                    }
                                                }

                                                throw throwable0;
                                            }

                                            if (directoryStream != null) {
                                                directoryStream.close();
                                            }

                                            return string1;
                                        }

                                        if (directoryStream != null) {
                                            directoryStream.close();
                                        }

                                        return string1;
                                    }

                                    if (directoryStream != null) {
                                        directoryStream.close();
                                    }

                                    return string1;
                                }

                                if (directoryStream != null) {
                                    directoryStream.close();
                                }

                                return string1;
                            }

                            if (directoryStream != null) {
                                directoryStream.close();
                            }

                            return string1;
                        }

                        if (directoryStream != null) {
                            directoryStream.close();
                        }
                    } catch (Exception exception) {
                        exception.printStackTrace();
                        return "IOError";
                    }

                    return !_boolean ? "EmptyContentsFolder" : this.validateFileTypes(path0);
                }
            }
        } catch (IOException iOException) {
            iOException.printStackTrace();
            return "IOError";
        }
    }

    public String getExtendedErrorInfo(String error) {
        if ("FolderNotAllowedInContents".equals(error)) {
            return "buildings/ creative/ mods/";
        } else {
            return "FileTypeNotAllowed".equals(error) ? "*.exe *.dll *.bat *.app *.dylib *.sh *.so *.zip" : "";
        }
    }

    public boolean readWorkshopTxt() {
        String string0 = this.workshopFolder + File.separator + "workshop.txt";
        if (!new File(string0).exists()) {
            return true;
        } else {
            try {
                FileReader fileReader = new FileReader(string0);

                boolean _boolean;
                try {
                    BufferedReader bufferedReader = new BufferedReader(fileReader);

                    try {
                        String string1;
                        while ((string1 = bufferedReader.readLine()) != null) {
                            string1 = string1.trim();
                            if (!string1.isEmpty() && !string1.startsWith("#") && !string1.startsWith("//")) {
                                if (string1.startsWith("id=")) {
                                    String string2 = string1.replace("id=", "");
                                    this.setID(string2);
                                } else if (string1.startsWith("description=")) {
                                    if (!this.description.isEmpty()) {
                                        this.description = this.description + "\n";
                                    }

                                    this.description = this.description + string1.replace("description=", "");
                                } else if (string1.startsWith("tags=")) {
                                    this.tags.addAll(Arrays.asList(string1.replace("tags=", "").split(";")));
                                } else if (string1.startsWith("title=")) {
                                    this.title = string1.replace("title=", "");
                                } else if (!string1.startsWith("version=") && string1.startsWith("visibility=")) {
                                    this.visibility = string1.replace("visibility=", "");
                                }
                            }
                        }

                        _boolean = true;
                    } catch (Throwable throwable0) {
                        try {
                            bufferedReader.close();
                        } catch (Throwable throwable1) {
                            throwable0.addSuppressed(throwable1);
                        }

                        throw throwable0;
                    }

                    bufferedReader.close();
                } catch (Throwable throwable2) {
                    try {
                        fileReader.close();
                    } catch (Throwable throwable3) {
                        throwable2.addSuppressed(throwable3);
                    }

                    throw throwable2;
                }

                fileReader.close();
                return _boolean;
            } catch (IOException iOException) {
                iOException.printStackTrace();
                return false;
            }
        }
    }

    public boolean writeWorkshopTxt() {
        String string0 = this.workshopFolder + File.separator + "workshop.txt";
        File file = new File(string0);

        try {
            FileWriter fileWriter = new FileWriter(file);
            BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
            bufferedWriter.write("version=1");
            bufferedWriter.newLine();
            bufferedWriter.write("id=" + (this.PublishedFileId == null ? "" : this.PublishedFileId));
            bufferedWriter.newLine();
            bufferedWriter.write("title=" + this.title);
            bufferedWriter.newLine();

            for (String string1 : this.description.split("\n")) {
                bufferedWriter.write("description=" + string1);
                bufferedWriter.newLine();
            }

            String string2 = "";

            for (int _int = 0; _int < this.tags.size(); _int++) {
                string2 = string2 + (String)this.tags.get(_int);
                if (_int < this.tags.size() - 1) {
                    string2 = string2 + ";";
                }
            }

            bufferedWriter.write("tags=" + string2);
            bufferedWriter.newLine();
            bufferedWriter.write("visibility=" + this.visibility);
            bufferedWriter.newLine();
            bufferedWriter.close();
            return true;
        } catch (IOException iOException) {
            iOException.printStackTrace();
            return false;
        }
    }

    public static enum ItemState {
        None(0),
        Subscribed(1),
        LegacyItem(2),
        Installed(4),
        NeedsUpdate(8),
        Downloading(16),
        DownloadPending(32);

        private final int value;

        private ItemState(int int1) {
            this.value = int1;
        }

        public int getValue() {
            return this.value;
        }

        public boolean and(SteamWorkshopItem.ItemState other) {
            return (this.value & other.value) != 0;
        }

        public boolean and(long bits) {
            return ((long)this.value & bits) != 0L;
        }

        public boolean not(long bits) {
            return ((long)this.value & bits) == 0L;
        }

        public static String toString(long _long) {
            if (_long == (long)None.getValue()) {
                return "None";
            } else {
                StringBuilder stringBuilder = new StringBuilder();

                for (SteamWorkshopItem.ItemState itemState : values()) {
                    if (itemState != None && itemState.and(_long)) {
                        if (stringBuilder.length() > 0) {
                            stringBuilder.append("|");
                        }

                        stringBuilder.append(itemState.name());
                    }
                }

                return stringBuilder.toString();
            }
        }
    }
}
